/*
 * HTProperties.h
 *
 *  Created on: Mar 14, 2009
 *      Author: Andrzej Olchawa
 *      mailto: andrzejolchawa@gmail.com
 *      http://www.hardtechnology.org
 *      This is a part of the Armazd project, which is covered by
 *      GNU GPL v2 license.
 */

#ifndef AOPROPERTIES_H_
#define AOPROPERTIES_H_

/* Include section */
#include <iostream>
#include <string.h>
#include <hash_map>
#include <map>
#include <fstream>

#include "HTStringUtilities.h"
#include "HTException.h"
#include "HTConverter.h"
#include "HTPropertiesElement.h"

/* namespace declaration */
using namespace std;

/* Static definitions section */
#define MAP_OF_STRINGS map<string, string>

#define DEFAULT_DELIMITER "="
#define DEFAULT_COMMENT_TYPE "#"

/* HTProperties class definition */
class HTProperties
{

private:

	int numberOfElements;

	string propertiesFilePath;
	MAP_OF_STRINGS propertiesList;

	/* Supportive private functions */
	bool isCommentLine(const string &, const string & = DEFAULT_COMMENT_TYPE);
	bool extractKeyAndValueFromString(string &, string &,
			const string &, const string & = DEFAULT_DELIMITER); // TODO change of delimiter

	/* Loads properties from file to propertiesList */
	void loadProperties();

public:

	/* Constructors and destructor */
	HTProperties();
	HTProperties(string);
	virtual ~HTProperties();

	/* Getters and setters */
	string		   getPropertiesFilePath();
	MAP_OF_STRINGS getPropertiesList();
	int			   getNumberOfElements();

	/* Other functions */
	void printPropertiesList();
	void loadProperties(string);

	/* Operators */
	string operator[](const string);
	HTPropertiesElement operator[](const int);

};

#endif /* AOPROPERTIES_H_ */
